package org.example.demo01.controller;

import org.example.demo01.entity.Piece;
import org.example.demo01.service.BarcodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/v1/pieces")
public class BarcodeController {

    private final BarcodeService barcodeService;

    @Autowired
    public BarcodeController(BarcodeService barcodeService) {
        this.barcodeService = barcodeService;
    }

    @PostMapping("/generate/{pplansheet}")
    public ResponseEntity<Map<String, Object>> generatePieces(@PathVariable String pplansheet) {
        Map<String, Object> result = barcodeService.generatePieces(pplansheet);
        return new ResponseEntity<>(result, HttpStatus.CREATED);
    }
}